package smedi.ismedi.mobile.bff.controller.safetycheck;

import com.smedi.ismedi.safetycheck.dto.request.inspection.*;
import com.smedi.ismedi.safetycheck.dto.response.inspection.InspectionRecordResponse;
import com.smedi.ismedi.safetycheck.feign.RemoteInspectionRecordFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

@Slf4j
@RestController
@Api(tags = {"巡检记录接口"})
@RequestMapping("/mobilebff/v1/inspectionRecord")
@AllArgsConstructor
public class InspectionRecordController extends BaseController {
    private final RemoteInspectionRecordFeignApi remoteInspectionRecordFeignApi;

    /**
     * 添加巡检记录
     *
     * @param inspectionRecordRequest
     * @return
     */
    @ApiOperation(value = "添加巡检记录")
    @PostMapping("/addInspectionRecord")
    ResponseData<InspectionRecordResponse> addInspectionRecord(@Validated @ApiParam(value = "param", required = true) @RequestBody InspectionRecordRequest inspectionRecordRequest) {
        return remoteInspectionRecordFeignApi.addRecord(inspectionRecordRequest);
    }

    /**
     * 编辑巡检记录
     *
     * @param inspectionRecordRequest
     * @return
     */
    @ApiOperation("编辑巡检记录")
    @PostMapping("editInspectionRecord")
    ResponseData<InspectionRecordResponse> editInspectionRecord(@Validated @ApiParam(value = "param", required = true) @RequestBody InspectionRecordRequest inspectionRecordRequest) {
        return remoteInspectionRecordFeignApi.updateRecord(inspectionRecordRequest);
    }

    /**
     * 巡检日志列表
     *
     * @param queryInspectionRecordRequest
     * @return
     */
    @ApiOperation("巡检记录列表")
    @GetMapping("getInspectionRecordList")
    ResponseData<List<InspectionRecordResponse>> getInspectionRecordList(@Validated @SpringQueryMap QueryInspectionRecordListRequest queryInspectionRecordRequest) {
        return remoteInspectionRecordFeignApi.queryRecordList(queryInspectionRecordRequest);
    }
}
